<template>
  <header class="head-nav">
    <template>
      <el-col :span="6" class="logo-container">
        <img class="logo" src="../assets/logo.png" alt="logo" />
        <span class="title">后台信息管理系统</span>
      </el-col>
      <el-col :span="6" class="user">
        <span class="select">
          <i class="down"></i>
        </span>
        <div class="dropdown">
          <p @click="command('infoshow')">个人信息</p>
          <p @click="command('logout')">退出</p>
        </div>
        <div class="welcome">
          <p class="name">欢迎</p>
          <p class="name comename">
            {{ user.name ? user.name : "请填写姓名" }}
          </p>
        </div>
        <div class="userlogo" v-show="user.identity == 'employee'">
          <img src="../assets/user.svg" alt="userlogo" />
        </div>
        <div class="userlogo" v-show="user.identity == 'manager'">
          <img src="../assets/usermanager.svg" alt="userlogo" />
        </div>
      </el-col>
    </template>
  </header>
</template>

<script>
export default {
  name: "HeadNav",
  data() {
    return {
    }
  },
 created() {
  },
  computed: {
    user() {
      return this.$store.getters.user;
    },
  },
  mounted() {
    // console.log(this.user);
  },
  methods: {
    // showSelect() {
    //   this.$refs.dropdown.classList.toggle("active")
    // },
    showInfoList(value) {
      this.$router.push("./"+value);
    },
    logout(value) {
      this.$router.push("./"+value);
      localStorage.removeItem("userToken")
    },
    command(value) {
      console.log(value);
      switch (value) {
        case "infoshow":
          this.showInfoList(value);
          break;
        case "logout":
          this.logout(value);
          break;
      }
    },
  },
};
</script>

<style scoped>
.head-nav {
  width: 100%;
  height: 68px;
  min-width: 600px;
  padding: 5px;
  background-color: steelblue;
  color: #fff;
  border-bottom: 1px solid #2b3f55;
}
.logo-container {
  float: left;
  min-width: 300px;
}
.logo-container .logo {
  width: 57px;
  height: 57px;
  vertical-align: middle;
}
.logo-container .title {
  display: inline-block;
  line-height: 57px;
  margin-left: 10px;
  font-family: "Microsoft YaHei";
  font-weight: bold;
  font-size: 20px;
  letter-spacing: 2px;
  vertical-align: middle;
}
.user {
  float: right;
  min-width: 300px;
}
.user .userlogo {
  float: right;
  width: 40px;
  height: 57px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 5px;
}
.user .welcome {
  float: right;
  height: 57px;
  width: 70px;
  font-size: 14px;
  font-weight: bold;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.user .welcome .comename {
  color: lightblue;
}
.select {
  float: right;
  width: 20px;
  line-height: 63px;
}
i {
  border: solid black;
  border-width: 0 3px 3px 0;
  display: inline-block;
  padding: 3px;
  cursor: pointer;
}
.down {
  transform: rotate(45deg) translateY(-50%);
  -webkit-transform: rotate(45deg) translateX(-40%) translateY(-120%);
}
.dropdown {
  position: fixed;
  top: 68px;
  right: 0;
  width: 100px;
  border-radius: 5px;
  border: 1px #ddd solid;
  display: none;
  z-index: 1000;
}
.dropdown.active {
  display: block;
}
.dropdown p {
  height: 40px;
  line-height: 40px;
  text-align: center;
  color: black;
  font-size: 14px;
  cursor: pointer;
  background-color: #fff;
}
.dropdown p:hover {
  background-color: steelblue;
  border: 1px steelblue solid;
  color: #fff;
}
.dropdown:hover {
  display: block;
}
.select:hover + .dropdown {
  display: block;
}
</style>